/*
 * ManejoActivo.java
 *
 * Created on 28 de febrero de 2007, 10:15 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package com.ik.pbs.Manejadores;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Manejador {

    private static Manejador manager = null;
    private String query;

    public static Manejador getInstancia() {
        if (manager == null) {
            manager = new Manejador();
            return manager;
        }
        return manager;
    }

    /**
     * @return the query
     */
    public String getQuery() {
        return query;
    }

    /**
     * @param query the query to set
     */
    public void setQuery(String query) {
        this.query = query;
    }

    /**
     * @return the max
     */
    /*
     * METODO GENERICO PARA EJECUTAR CUALQUEIR QUERY QUERIDO EN LA BASE DE DATOS
     * EN LA QUE TENENOS CONEXION. ESTE METODO ES UNIVERSAL
     */
    public ResultSet ExecuteQuery(Connection con, String query) throws SQLException {


        ResultSet rs;

        PreparedStatement stat = con.prepareStatement(query,
                ResultSet.TYPE_SCROLL_INSENSITIVE,
                ResultSet.CONCUR_READ_ONLY);

        rs = stat.executeQuery();

        return rs;
    }
}

